package net.alegen.helloworld;

import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class MainActivity extends Activity implements OnClickListener {
	
	private TextThread textThread;	
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        
        Button btnHello = (Button)this.findViewById(R.id.btnHello);
        btnHello.setOnClickListener(this);
        
        this.textThread = new TextThread(new Handler(Looper.getMainLooper()),
        		(TextView)this.findViewById(R.id.textViewThread));
        this.textThread.start();
    }
    
    @Override
    public void onStop() {
    	super.onStop();
    	this.textThread.stopThread();
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }

	public void onClick(View v) {
		TextView txtView = (TextView)this.findViewById(R.id.txtViewHello);
		txtView.setText("Hello to you too!");
	}
}
